import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/styles/index.scss' // global css

import echarts from "echarts"
Vue.prototype.$echarts = echarts

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

// 全局常量
import AppConstant from '@/constant/AppConstant'
// 全局工具类
import CommonUtils from '@/utils/CommonUtils'
// 全局方法
import { attachUrl, parseTime, getBeforeDay, getLastMonth, resetForm } from '@/utils/index'
// 权限指令
import permission from '@/directive/permission'
// 全局过滤器
import * as filters from '@/filters'
// 全局组件
import RightToolbar from '@/components/RightToolbar'
import Pagination from '@/components/Pagination'
import { FlexBox, FlexBoxItem } from '@/components/FlexBox'

// 注册全局对象、方法
Vue.prototype.$constant = AppConstant
Vue.prototype.$common = CommonUtils
Vue.prototype.attachUrl = attachUrl
Vue.prototype.parseTime = parseTime
Vue.prototype.getBeforeDay = getBeforeDay
Vue.prototype.getLastMonth = getLastMonth
Vue.prototype.resetForm = resetForm

// 注册全局指令
Vue.use(permission)

// 注册全局组件
Vue.component('RightToolbar', RightToolbar)
Vue.component('Pagination', Pagination)
Vue.component('flex-box', FlexBox)
Vue.component('flex-box-item', FlexBoxItem)

Vue.use(ElementUI)

// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
